#include <stdio.h>
#include "machine.h"

entry gcd()
{
  new_env(2, 0);

  ildc(0);
  load();
  ildc(0);
  iequal();
  jz(label1);

  ildc(1);
  load();
  ret();

 label1:
  ildc(0);
  load();
  ildc(1);
  load();
  ilt();
  jz(label2);

  ildc(1);
  load();
  ildc(0);
  load();
  call(gcd);
  ret();

 label2:
  ildc(0);
  load();
  ildc(1);
  load();
  isub();
  ildc(1);
  load();
  call(gcd);
  ret();
}



entry sugar_main()
{
  new_env(0,2);

  ildc(B_SCAN_INT);
  builtin();

  ildc(B_SCAN_INT);
  builtin();

  call(gcd);
  ildc(B_PRINT_INT);
  builtin();
  return;
}

static_area_initialization()
{
  region_table[0] = 0;
}
